<?php
	require_once (dirname(__FILE__)."/../../config/Config.inc");
	require_once (dirname(__FILE__)."/../../config/api.inc");
	require_once ("load.php");
	
	$parm = requestArrayParm($_REQUEST);
	
	$result['status'] = '1';
	
	unset($wheres, $pages, $sorts,$list);
	
	$wheres['userid'] = $userinfo['id'];
	
	if($parm['status'] == '1')
	{
		//返利
		$wheres['money'] = array('>',0);
	}
	else if($parm['status'] == '2')
	{
		//提现
		$wheres['money'] = array('<',0);
	}
	
	$wheres['addtime'] =  array('<=',time());
	
	$sorts['id'] = 'desc';
	$resData = _SqlTool::getList('jyinfo', $wheres, $pages, $sorts);
	
	foreach ($resData as $key => $val)
	{
		unset($temp);
		$temp['title'] = $val['title'];
		if($val['money']>=0)
		{
			$temp['type'] = '1';
			$temp['money'] = '+'.$val['money'];
		}
		else
		{
			$temp['type'] = '2';
			$temp['money'] = $val['money'];
		}
		
		$temp['time'] = date('Y-m-d H:i:s',$val['addtime']);
		
		unset($wheres,$between);
	
		$wheres['userid'] = $userinfo['id'];
		
		$wheres['id'] =  array('<=',$val['id']);
		
		$wheres['addtime'] =  array('<=',time());
		
		$temp['yue'] = _SqlTool::getSum('jyinfo', $wheres, $between, 'money');
		
		$list[] = $temp;
	}
	
	$result['list'] = $list;
	
	echoJSON($result);